#include<bits/stdc++.h>
#define db double
using namespace std;
using ll=long long;
const int N=500,M=3e5+5,P=998244353;
int n,p[M];
ll pp;
ll f[2][N][N];
inline ll ksm(ll a,int b){
	ll res=1;
	while(b){
		if(b&1)res=res*a%P;
		a=a*a%P,b>>=1; 
	}
	return res;
}
ll noww;
inline int gt(int x,int y){
//	db res=0;
	if(x==y){
		return noww;
	}
	return pp;
}
int tr[M];
inline void upd(int x){while(x<=n)tr[x]++,x+=x&(-x);}
inline int qry(int x){
	int res=0;
	while(x)res+=tr[x],x-=x&(-x);
	return res; 
}
inline int solve(int pr){
	int res=0;
	for(int i=1;i<=n;i++)tr[i]=0;
	for(int i=1;i<=n;i++){
		res+=qry(n)-qry(p[i]);
		upd(p[i]);
	}
	return res;
}
int k,q;
int main(){
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>k>>q;
	pp=1ll*n*(n-1)/2%P;
	pp=ksm(pp,P-2);noww=ksm(1ll*n*(n-1)/2-1ll*(n-1)*(n-2),P-2)*pp%P;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	int x,y;
	for(int i=1;i<=q;i++){
		cout<<solve(k-i+1)<<"\n";
		cin>>x>>y;
		swap(p[x],p[y]);
	}
	cout<<solve(k-q)<<"\n";
	return 0;
}

